{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%classpath add mvn org.xerial sqlite-jdbc 3.27.2.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "val conn = BxDriverManager.getConnection(\"jdbc:sqlite:sample.db\");  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    " try{  \n",
    "    val sql = \"CREATE TABLE IF NOT EXISTS Person ( id integer PRIMARY KEY,  name text NOT NULL);\";  \n",
    "    val stmt = conn.createStatement();  \n",
    "    val result  = stmt.execute(sql);  \n",
    "    val dbm = conn.getMetaData();\n",
    "    val tables = dbm.getTables(null, null, \"Person\", null);\n",
    "     while (tables.next()) { \n",
    "           val  tName = tables.getString(\"TABLE_NAME\");\n",
    "            if (tName != null && tName.equals(\"Person\")) {\n",
    "                println(\"table '\"+tName+\"' exists \");  \n",
    "                val tExists = true;\n",
    "            }\n",
    "        } \n",
    " } finally{\n",
    "     conn.close()\n",
    " } "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import java.sql.DriverManager\n",
    "java.sql.DriverManager.getConnection(\"jdbc:sqlite:sample.db\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Scala",
   "language": "scala",
   "name": "scala"
  },
  "language_info": {
   "codemirror_mode": "text/x-scala",
   "file_extension": ".scala",
   "mimetype": "",
   "name": "Scala",
   "nbconverter_exporter": "",
   "version": "2.11.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": false,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
